#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

class Solution {
public:
	string longestCommonPrefix(vector<string> &strs) {
		string common;
		char c;
		if (strs.size() == 0) return "";
		for (int i = 0; i < strs[0].length(); ++i){
			c = strs[0][i];
			bool isSub = true;
			for (int j = 1; j < strs.size(); ++j){
				if (i == strs[j].length() || c != strs[j][i]){
					isSub = false;
					break;
				}
			}
			if (!isSub)
				break;
			else
				common.push_back(c);
		}
		return common;
	}
};
int main(int argc, char** argv){
	vector<string> strs{"abca", "abc"};
	cout << Solution().longestCommonPrefix(strs) << endl;
	return 0;
}